<script>
  import config from './config'
  import store from '@/store'
  import { getToken } from '@/utils/auth'
  // var jpushModule = uni.requireNativePlugin("JG-JPush")
  export default {
	  data(){
		  return {
			  version:'',
		  }
	  },
	  onShow(){
		  console.log('onLoad');
		  // #ifdef APP-PLUS
		    plus.runtime.setBadgeNumber(0);
		  // #endif
		
		   
	  },
    onLaunch: function() {
        this.initApp()
		// #ifdef APP
		  console.log('plus.runtime.appid',plus.runtime.appid);
		 //获取你打包时设置的版本号，然后设置到storage里
		    plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
		 	   console.log(wgtinfo)
		 	   uni.setStorage({
		 		   key: 'wgtinfoVersion',
		 		   data: wgtinfo.version
		 	   })
		    })
		 uni.onPushMessage((res) => {  
		            console.log("收到推送消息：",res) //监听推送消息  
				
					if(res){
						uni.switchTab({
							url:'/pages/RelateTome/RelateTome'
						})
						
						plus.runtime.setBadgeNumber(0);
					}
		})  
		// #endif
		
		
	
		    
    },
    methods: {
      // 初始化应用
      initApp() {
        // 初始化应用配置
        this.initConfig()
        // 检查用户登录状态
        //#ifdef H5
         // this.checkLogin()
        //#endif
      },
	 
	 
      initConfig() {
        this.globalData.config = config
      },
      checkLogin() {
        if (!getToken()) {
          this.$tab.reLaunch('/pages/login') 
        }
      }
    }
  }
</script>

<style lang="scss">
  @import "@/uni_modules/uview-ui/index.scss";
  @import '@/static/scss/index.scss';
  @import '@/static/font/iconfont.css'
</style>
